<?php

namespace App\Models\V1;


use Illuminate\Database\Eloquent\Factories\HasFactory;


class Estate extends BaseModel
{
    use HasFactory;

    protected $connection;
    protected $table = 'wy_estate';
    protected $fillable=['id','title','content','show','community_id','community_name','preparatory_id','preparatory_name','state'];



    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);
        $this->connection = config('database.connections.wuye.database');
    }

    /**
     * 状态
     * @param $key
     * @return string
     */
    public function getStateAttribute($key)
    {
        return (string) $key;
    }





    // 定义修改器，将数组转换为 JSON
    public function setShowAttribute($value)
    {
        $this->attributes['show'] = json_encode($value);
    }


    // 定义访问器，将 JSON 转换为数组
    public function getShowAttribute($value)
    {
        return json_decode($value, true);
    }















}
